package de.tudarmstadt.ukp.muip.fibqdojo.rule;

import de.tudarmstadt.ukp.muip.fibqdojo.interfaces.IFIBQMatchMode;
import de.tudarmstadt.ukp.muip.fibqdojo.interfaces.IFIBQRule;
import de.tudarmstadt.ukp.muip.fibqdojo.interfaces.IFIBQSentence;
import de.tudarmstadt.ukp.muip.fibqdojo.interfaces.IFIBQSentenceToken;
import de.tudarmstadt.ukp.muip.fibqdojo.visitor.GetPartOfSpeechVisitor;

public class PartOfSpeechMatchingRule implements IFIBQRule {

    private final String partOfSpeech;
    private final IFIBQMatchMode matchMode;

    public PartOfSpeechMatchingRule(String partOfSpeech, IFIBQMatchMode matchMode) {
        this.partOfSpeech = partOfSpeech;
        this.matchMode = matchMode;
    }

    @Override
    public boolean match(IFIBQSentence sentence) {
        return false;
    }

    @Override
    public boolean match(IFIBQSentenceToken sentenceToken) {
        GetPartOfSpeechVisitor posVisitor = new GetPartOfSpeechVisitor();
        sentenceToken.accept(posVisitor);
        if (matchMode.match(posVisitor.getPartOfSpeech(), partOfSpeech)) {
            return true;
        }
        return false;
    }


}
